#include<bits/stdc++.h>
using namespace std;
int main(){
	string word;
	string str;
	cin >> word;
//	getline( cin , word );
//	getline( cin , str );
	vector<string>wh;
	
	while(1){
		string str;
		cin >> str;
		wh.push_back(str);
		char c = getchar();
		if( c == '\n' ) break;
	}
	int cnt = 0 , index = -1;
	bool flag = true;
	for( int i = 0 ; i < wh.size() ; i++ ){
		if( wh[i] == word ){
			cnt++;
			if( flag ){
				index = i;
				flag = false;
			}
		}
	} 
	if( index == -1 ) cout << -1;
	else{
		int ans = 0;
		for( int i = 0 ; i < index ; i++ ){
			ans += wh[i].length() + 1; 
		} 
		cout << cnt << " " << ans;
	} 
	return 0;
}
